# Contributor: Róbert Nagy <vrnagy@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libcec
pkgver=6.0.2
pkgrel=8
pkgdesc="libcec for the Pulse-Eight USB-CEC adapter"
url="https://github.com/Pulse-Eight/libcec"
arch="all"
license="GPL-2.0-or-later"
depends_dev="
	eudev-dev
	libxrandr-dev
	python3-dev
	swig
	"
makedepends="$depends_dev
	cmake
	linux-headers
	p8-platform-dev
	samurai
	"
subpackages="$pkgname-dev py3-$pkgname:py3 $pkgname-tools"
source="https://github.com/Pulse-Eight/libcec/archive/libcec-$pkgver.tar.gz
	0001-Add-an-udev-rule-making-the-CEC-adapter-part-of-the-input-group.patch
	fix-null-return.patch
	"

builddir="$srcdir/libcec-libcec-$pkgver"

build() {
	cmake -G Ninja -B build \
		-DHAVE_LINUX_API=1 \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

py3() {
	amove usr/lib/python*
}

tools() {
	pkgdesc="$pkgdesc (tools)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin
}

sha512sums="
c16ac268e67b01d4e35fad644e5927e1d9fc7bcaeff698ac5f0eadd31ec63a0bef2a2b2bc37860d1571e1e0cdc55911c2de468c661c7c7ae1d492f80188035cb  libcec-6.0.2.tar.gz
7b361ac6d7dd825bd7667085682cbc503796caf3a54966ebe0981189cf39cd34f2fde283dab73e5e883aa21c7f4b3ad0d34c2d260ce03219b083e555f6c521af  0001-Add-an-udev-rule-making-the-CEC-adapter-part-of-the-input-group.patch
0aa63e622ecf3d9009efc06db801c7a5558aa30a0543701e2e12bf052a54155240fc2d2bf339aab1af7288c3e85c7edf5087e4de6ce800398fba05897cf6d22f  fix-null-return.patch
"
